package com.whmnx.chitchat.utils;

import android.graphics.Bitmap;
import android.text.TextUtils;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.BitmapImageViewTarget;
import com.whmnx.chitchat.R;
import com.whmnx.chitchat.constants.Constants;
import com.whmnx.chitchat.view.TransformationUtils;


/**
 * author : huang
 * date   : 2019/10/29 0029 17:43
 * version: 1.0
 * @author Administrator
 */
public class ImageUtil {

    private static RequestOptions options;

        public static void setImage(ImageView imageView, String url) { // 磁盘缓存策略
             options = new RequestOptions().error(R.mipmap.logo).override(580).dontAnimate();// 不使用磁盘缓存 override(680);

        if (!TextUtils.isEmpty(url) && url.contains("http")){
                Glide.with(imageView.getContext()).load(url)
                        .apply(options)
                        .into(imageView);
        }else {
            // String url2  = url.replace("\\", "");
            Glide.with(imageView.getContext()).load(Constants.HOST2 + url)
                    //   .transition(withCrossFade())
                    .apply(options)
                    .into(imageView);
        }
    }
}
